<template>
  <div>
    <van-row style="padding-top:1rem;padding-bottom: 1rem">
        <van-col span="24"> <heardes /> </van-col>
        <van-col span="5"> <left /> </van-col>
      <van-col span="7">
         
        <table>
          <tr>
            <th>工作流编号</th>
            <th>工作流名称</th>
<!--            <th>工作流参数</th>-->
          </tr>
          <tr v-for="(i,index) in worklists" @click="selectwork(index)" :key="i.id">
            <td>{{i.id}}</td>
            <td>{{i.name}}</td>
          </tr>
        </table>
      </van-col>
      <van-col span="12"><p>{{worklist['name']}}</p>
        <div v-for="i in worklist['params']" :key="i.id" align="left">
          <van-field :label="i.name" v-if="i.type=='input'" v-model="tfvalue['name']" />
          <el-select  v-if="i.type=='select'" v-model="tfvalue['type']">
            <el-option :value="j.name" v-for="j in i['value']" :key="j.name">{{j.name}}</el-option>
          </el-select>
          <div class="block" v-if="i.type=='datetime'" >
            <el-date-picker
                v-model="tfvalue['datetime']"
                type="datetimerange"
                start-placeholder="Start Date"
                end-placeholder="End Date"
                :default-time="defaultTime"
            >
            </el-date-picker>
          </div>
          <van-uploader v-if="i.type=='file'" v-model="tfvalue['file']" />
        </div><van-button> 提交 </van-button></van-col>

    </van-row>
  </div>
</template>

<script>
import myaxios from "../../http/axios";
import heardes from '../comm/heardes.vue';
import Left from '../comm/left.vue';

export default {
  components: { heardes, Left },
  name: "workf_show",
  data(){
    return{
      id:1,
      worklists:[],
      worklist:{},
      // 时间
      value1:[],
      // 默认时间
      defaultTime:[new Date(2021,12,22,0,0,0)],
      // 绑定的数据
      tfvalue:{},
    }
  },
  methods:{
    selectwork(index){
      this.worklist=this.worklists[index]
      console.log(this.worklist)
    },
    getworkf(){
      myaxios("query_workflow","get").then(res=>{
        let lst = res.list
        for(var i =0;i<lst.length;i++){
          lst[i]["params"]=JSON.parse(res.list[i]["params"])
        }
        this.worklists=lst
        // console.log(this.worklists)
      })
    }
  },
  mounted() {
    this.getworkf()
  }
}
</script>

<style scoped>

</style>